/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/
/*
This files contains definitions of types used in the context of HW assignment 1,
and special constants and conversion functions related to these types. 

Created by Amnon Drory for the course "Introduction To Systems Programming", 
School of Electrical Engineering, Tel-Aviv University. winter 2012.
*/
/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/

#ifndef HW1_TYPES_H
#define HW1_TYPES_H

/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/

#include <stdlib.h> /* for atoi(), atof() */ 

/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/

typedef enum { FALSE = 0, TRUE = 1 } BOOL;

/**
 * TProductID is the type used to store the ID of a product
 */ 
typedef int TProductID;
#define ILLEGAL_PRODUCT_ID (-1)

/**
 * String2TProductID receives a string and converts its value into a variable 
 * of type TProductID.
 */ 
#define String2TProductID atoi

/*o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.*/

/**
 * TUserID is the type used to store the ID of a user
 */ 
typedef int TUserID;

/**
 * String2TUserID receives a string and converts its value into a variable 
 * of type TUserID .
 */ 
#define String2TUserID atoi

/*o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.*/

/**
 * TMoney is the type used for storing amounts of money.
 */ 
typedef double TMoney;

/**
 * String2TMoney receives a string and converts its value into a variable 
 * of type TMoney.
 */ 
#define String2TMoney atof

/*o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.*/

/**
 * TOperation represents the possible operations that can be requested of
 * the store, such as Buy, Sell, Save Status, and more. 
 */ 
typedef enum { 
    FIRST_OPERATION = 0,
    IM_SELL_TO_CUSTOMER = 0, 
    IM_BUY_FROM_SUPPLIER = 1, 
    IM_CREATE_INVENTORY_FILE = 2, 
    IM_ADD_INVENTORY_FROM_FILE = 3, 
    NUM_OF_INPUT_OPERATIONS = 4,
    IM_END_OF_INPUT,
    IM_NO_OPERATION,
    } 
TOperation;

/*o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.*/

/**
 * TTransaction represents the details of one purchase - the ID of the product
 * and the amount paid for it.
 */ 
typedef struct 
{
    TUserID UserID;
    TProductID ProductID;
    TMoney Cost;
} TTransaction;

/*o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.o.*/

/**
 * TRequest represents a command accepted from input. 
 */ 
typedef struct 
{
    char* Filename;
    TOperation Operation;
    TTransaction TransactionData;    
} TRequest;

/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/

#endif // HW1_TYPES_H